<?php

class authority_model extends jqxGrid_CI_Model {

    function __construct()
    {
        parent::__construct();
        
    }
    function get($ID=""){
        $where=array("ID"=>$ID);
        $query=$this->db->get_where('tbl_authority', $where); 
        return $query->result();
    }
    function gets(){
        $query=$this->db
                ->where("Keyword !=","admin")
                ->get('tbl_authority'); 
        return $query->result();
    }
    function update($ID,$Params){
        $this->db->set('Update', "NOW()",false);
        $this->db->where('ID', $ID);
        $this->db->update('tbl_authority', $Params); 
        $count = $this->db->affected_rows(); //should return the number of rows affected by the last query
        if($count==1) return true;
        return false;
    }
    function insert($Params){
        $this->db->set('Insert', "NOW()",false);
        $this->db->insert('tbl_authority', $Params); 
        $count = $this->db->affected_rows(); //should return the number of rows affected by the last query
        if($count==1) return true;
        return false;
    }
    function delete($ID){
        $this->db->set('Delete', "NOW()",false);
        $this->db->where('ID', $ID);
        $this->db->update('tbl_authority'); 
        $count = $this->db->affected_rows(); //should return the number of rows affected by the last query
        if($count==1) return true;
        return false;
    }
    function binding(){
        $strQuery="
            SELECT SQL_CALC_FOUND_ROWS `tbl_authority`.*
            FROM `tbl_authority`
            ";
        $strWhere="
            WHERE  true
            ";
        $strOrderBy="Order By `Name` ASC ";
        $strGroupBy="";
        $config=array(
            "strQuery"=>$strQuery,
            "strWhere"=>$strWhere,
            "strOrderBy"=>$strOrderBy,
            "strGroupBy"=>$strGroupBy,
            "usingLimit"=>false,
            "fields"=>array(),
            "datefields"=>array()
        );
        $this->init($config);
        return $this->jqxBinding();
    }
    
}
?>
